app.controller("brandController",function ($scope,$http,$controller,brandService) {

    //控制器继承
    $controller("baseController",{$scope:$scope})

    $scope.findAll=function () {
        brandService.findAll().success(function (res) {
            $scope.list=res;
        })
    }


    // $scope.findPage=function (page,size) {
    //     $http.get("../brand/findPage.do?page="+page+"&size="+size).success(function (res) {
    //         $scope.list=res.rows;
    //         $scope.paginationConf.totalItems=res.total;
    //     })
    // }

    $scope.save=function () {
        var  method= brandService.add($scope.entity);
        if ($scope.entity.id!=null){
            method=brandService.update($scope.entity);
        }
        method.success(function (res) {
            if (res.success){
                $scope.reloadList();
            } else {
                alert(res.msg)
            }
        })
    }


    $scope.findOne=function (id) {
        $http.get("../brand/findOne.do?id="+id).success(function (res) {
            $scope.entity=res;
        })
    }


    //删除品牌
    $scope.delete=function () {
        if(confirm('确定要删除吗？')){
            brandService.delete( $scope.selectIds).success(function (res) {
                if (res.success){
                    $scope.reloadList();
                } else {
                    alert(res.msg)
                }
            })
        }
    }

    $scope.searchEntity={};
    //查询
    $scope.search=function (page,size) {
        brandService.search(page, size,$scope.searchEntity).success(function (res) {
            $scope.list=res.rows;
            $scope.paginationConf.totalItems=res.total;
        })
    }


})
